package com.example.demo.controller;

import com.example.demo.domain.UserEntity;
import com.example.demo.service.interfaces.IUserMyBatisService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/userMyBatis")
@Api(value = "DoctorTestController-医生信息接口模拟",description = "用户模块接口")
public class UserMyBatisTestController {

    @Autowired
    private IUserMyBatisService userMyBatisService;

    @CrossOrigin(origins = "http://www.w3school1.com.cn")
    @ResponseBody
    @RequestMapping(value = "save",method = RequestMethod.POST)
    public int addUser(@RequestBody UserEntity userEntity) {
        System.out.println(userEntity.toString());
        return userMyBatisService.addUser(userEntity);
    }

    @CrossOrigin
    @ResponseBody
    @RequestMapping(value = "query/{pageIndex}/{pageSize}",method = RequestMethod.GET)
    public Object queryUser(@PathVariable("pageIndex") int pageIndex, @PathVariable("pageSize") int pageSize) {
        PageInfo<UserEntity> allUser = userMyBatisService.findAllUser(pageIndex, pageSize);

        return allUser;
    }
}
